<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改菜单</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
<link rel="stylesheet" href="__PUBLIC__/admin/css/admin.css">
</head>
<body class="layui-bg-gray">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md12 layui-col-xs12">
				<div class="layui-card">
					<div class="layui-card-body">
						<form class="layui-form" action="">
							<div class="layui-form-item">
								<label class="layui-form-label">上级菜单</label>
								<div class="layui-input-block">
									<select name="pid" lay-verify="required">
										<option value=""></option>
										<option value="0">顶级菜单</option>
										<volist name="menus" id="menu">
										<option value="{$menu.id}">{$menu.name}</option>
										<notempty name="menu.children"> <volist
											name="menu['children']" id="children">
										<option value="{$children.id}">&nbsp;&nbsp;&nbsp;&nbsp;{$children.name}</option>
										<notempty name="children.children"> <volist
											name="children['children']" id="child">
										<option value="{$child.id}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$child.name}</option>
										</volist> </notempty> </volist> </notempty> </volist>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">图标</label>
								<div class="layui-input-block">
									<select id="icon" name="icon" lay-verify="required">
										<option value=""></option>
										<option value="fa-home">home</option>
										<option value="fa-user">user</option>
										<option value="fa-users">users</option>
										<option value="fa-list">list</option>
										<option value="fa-calendar">calendar</option>
										<option value="fa-desktop">desktop</option>
										<option value="fa-cog">cog</option>
										<option value="fa-cogs">cogs</option>
										<option value="fa-cubes">cubes</option>
										<option value="fa-comments">wechat</option>
										<option value="fa-picture-o">picture</option>
										<option value="fa-bar-chart-o">charts</option>
										<option value="fa-envelope">envelope</option>
										<option value="fa-search">search</option>
										<option value="fa-shopping-cart">cart</option>
										<option value="fa-info-circle">info</option>
										<option value="fa-ticket">ticket</option>
										<option value="fa-tachometer">tachometer</option>
										<option value="fa-trash-o">trash</option>
										<option value="fa-table">table</option>
										<option value="fa-bolt">blot</option>
										<option value="fa-money">money</option>
										<option value="fa-trophy">trophy</option>
										<option value="fa-indent">indent</option>
										<option value="fa-outdent">outdent</option>
									</select>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">菜单名称</label>
								<div class="layui-input-block">
									<input type="text" name="menu_name" required
										value="{$obj.menu_name}" lay-verify="required"
										placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">模块</label>
								<div class="layui-input-block">
									<input type="text" name="module" required lay-verify="required"
										value="{$obj.module}" placeholder="请输入模块名" autocomplete="off"
										class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">方法</label>
								<div class="layui-input-block">
									<input type="text" name="action" required lay-verify="required"
										value="{$obj.action}" placeholder="请输入方法名" autocomplete="off"
										class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">排序</label>
								<div class="layui-input-block">
									<input type="text" name="sort_order" required
										lay-verify="required" value="{$obj.sort_order}"
										autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-input-block">
									<button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
								</div>
							</div>
						</form>
						<input type="hidden" name="nid" value="{$obj.id}" />
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="__PUBLIC__/layui/layui.js"></script>
	<script type="text/javascript"
		src="__PUBLIC__/common/js/jquery-2.0.3.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$("select[name='icon'] option").each(function(){
				var content = "{$obj.icon}";
				if($(this).val() == content) {
					$(this).attr('selected', 'selected');
				}
			});
			$("select[name='pid']").val({$obj.pid});
			layui.use('form', function() {
				var form = layui.form;
				form.on('submit(formDemo)', function(data) {
					//layer.msg(JSON.stringify(data.field));
					var index = layer.load();
					var nid = $("input[name='nid']").val();
					$.ajax({
						type : "POST",
						url : "{:U('Settings/editMenu')}",
						data : {
							nid  : nid,
							info : data.field
						},
						success : function(res) {
							layer.close(index);
							if (res.status == 1) {
								layer.msg(res.info);
								layui.data('cache', {
									key : 'status',
									value : true
								});
							} else {
								layer.msg(res.info);
							}
						}
					});
					return false;
				});
			});
		});
	</script>
</body>
</html>